home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Pictures / TIFF / Tiff Utilties / Tiff Window DEMO / update.c < prev   
C/C++ Source or Header  |  1990-04-11  |  2KB  |  70 lines

  1. #include "my color.h"
  2. do_update(the_event)
  3. EventRecord    *the_event;
  4. {
  5. CGrafPtr        the_tiff_picture;
  6. Rect            erase_rect, draw_rect, tempRect;
  7. CWindowPtr        active_window;
  8. short            i, number_of_pm_entries = 255;
  9.  
  10.     GetPort(&savedPort);                            /* SAVE THE CURRENT P0RT    */
  11.     active_window = (CWindowPtr)the_event->message;
  12.     SetPort((GrafPtr)active_window);                /* SET PORT TO THE ONE NEEDING UPDATING    */
  13.  
  14.     if(active_window)
  15.     {
  16.     
  17.         the_tiff_picture = (CGrafPtr)GetWRefCon(active_window);    
  18.         erase_rect = active_window->portRect;
  19.         erase_rect.bottom -= BAR_WIDTH;                /* Don't erase the scroll bars. If you do, they will flicker terribly */
  20.         erase_rect.right -= BAR_WIDTH;
  21.         BeginUpdate(active_window); 
  22.         EraseRect(&erase_rect);
  23.         SetRect(&tempRect, number_of_pm_entries, number_of_pm_entries, number_of_pm_entries, number_of_pm_entries);
  24. /*
  25.         for (i = 2; i <= number_of_pm_entries; i++) 
  26.         {
  27.             PmForeColor(i);
  28.             FrameOval (&tempRect);
  29.             InsetRect (&tempRect, -1, -1);
  30.         }
  31. */
  32.         if(the_tiff_picture)    /* only copy the picture into the window if there is actually a picture */
  33.         {
  34.             draw_rect = active_window->portRect;    /* define the destination rectangle for the PixMap */
  35.             draw_rect.bottom = draw_rect.top + ((*the_tiff_picture).portRect.bottom - (*the_tiff_picture).portRect.top);
  36.             draw_rect.right = draw_rect.left + ((*the_tiff_picture).portRect.right - (*the_tiff_picture).portRect.left);
  37.             HLock((*the_tiff_picture).portPixMap);
  38.             HLock((*active_window).portPixMap);
  39.             CopyBits(    *(*the_tiff_picture).portPixMap, 
  40.                         *(*active_window).portPixMap, 
  41.                         &(*the_tiff_picture).portRect, 
  42.                         &draw_rect, 
  43.                         srcCopy, 0L);
  44.             HUnlock((*active_window).portPixMap);
  45.             HUnlock((*the_tiff_picture).portPixMap);
  46.             ActivatePalette(active_window);
  47.         }
  48.         DrawControls(active_window);
  49.         DrawGrowIcon(active_window);
  50.         EndUpdate(active_window);
  51.  
  52.     
  53.     }
  54.     else
  55.     {
  56.         erase_rect = active_window->portRect;
  57.         erase_rect.bottom -= (BAR_WIDTH + ONE_PIXEL);    /* Don't erase the scroll bars. If you do, they will flicker terribly */
  58.         erase_rect.right -= (BAR_WIDTH + ONE_PIXEL);
  59.         BeginUpdate(active_window); 
  60.         EraseRect(&erase_rect);
  61.         DrawControls(active_window);
  62.         DrawGrowIcon(active_window);
  63.         EndUpdate(active_window);
  64.         
  65.     }
  66.     SetPort(savedPort);        /* set port to original port */
  67. }
  68.  
  69.  
  70.